<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改保险金内容')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-content-edit" th:object="${recordBenefitContent}">
            <input name="contentId" id="contentId" th:field="*{contentId}" type="hidden">
            <input name="benefitId" id="benefitId" th:field="*{benefitId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">所属用户：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="userId" type="hidden" th:field="*{userId}"  />
                        <input class="form-control" type="text" onclick="selectUserTree()" id="treeName" readonly="true" th:field="*{userName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">申报类别：</label>
                <div class="col-sm-8">
                    <select name="benefitType" class="form-control m-b" th:with="type=${@dict.getType('basic_benefit_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{benefitType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">机关事业养老(单位)：</label>
                <div class="col-sm-8">
                    <input name="a1" th:field="*{a1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">机关事业养老(个人)：</label>
                <div class="col-sm-8">
                    <input name="a2" th:field="*{a2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">企业养老(单位)：</label>
                <div class="col-sm-8">
                    <input name="b1" th:field="*{b1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">企业养老(个人)：</label>
                <div class="col-sm-8">
                    <input name="b2" th:field="*{b2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">失业(单位)：</label>
                <div class="col-sm-8">
                    <input name="c1" th:field="*{c1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">失业(个人)：</label>
                <div class="col-sm-8">
                    <input name="c2" th:field="*{c2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">医疗(单位)：</label>
                <div class="col-sm-8">
                    <input name="d1" th:field="*{d1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">医疗(个人)：</label>
                <div class="col-sm-8">
                    <input name="d2" th:field="*{d2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">工伤：</label>
                <div class="col-sm-8">
                    <input name="e" th:field="*{e}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">职业年金(单位)：</label>
                <div class="col-sm-8">
                    <input name="f1" th:field="*{f1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">职业年金(个人)：</label>
                <div class="col-sm-8">
                    <input name="f2" th:field="*{f2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">公务员医疗：</label>
                <div class="col-sm-8">
                    <input name="g" th:field="*{g}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">企业年金(单位)：</label>
                <div class="col-sm-8">
                    <input name="h1" th:field="*{h1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">企业年金(个人)：</label>
                <div class="col-sm-8">
                    <input name="h2" th:field="*{h2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">公积金(单位)：</label>
                <div class="col-sm-8">
                    <input name="j1" th:field="*{j1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">公积金(个人)：</label>
                <div class="col-sm-8">
                    <input name="j2" th:field="*{j2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">滞纳金：</label>
                <div class="col-sm-8">
                    <input name="k" th:field="*{k}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "record/benefit/content";
        $("#form-content-edit").validate({
            focusCleanup: true
        });

        /* 选择人员 */
        function selectUserTree() {
            var options = {
                title: '选择员工',
                width: "380",
                url: ctx + "basic/user/selectTree",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var treeType = body.find('#treeType').val();
            if(treeType == 'user'){
                var id = body.find('#treeId').val();
                var treeId = id.substring(id.indexOf('_') + 1, id.length);
                $("#treeId").val(treeId);
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
                checkBenefitContent();
            }else{
                $.modal.alertError("请选择员工");
            }
        }

        function checkBenefitContent(){
            $.ajax({
                type: "post",
                url: prefix + "/checkBenefitContent",
                dataType: 'json',
                data: {
                    userId: $("#treeId").val(),
                    contentId: $("#contentId").val(),
                    benefitId: $("#benefitId").val()
                },
                success: function(r) {
                    if (r.code != web_status.SUCCESS) {
                        $.modal.msgError('当前人员已存在工资记录');
                    }
                    $.modal.closeLoading();
                }
            });
        }

        function submitHandler() {
            if ($.validate.form()) {
                var treeId = $("#treeId").val();
                if(treeId == '') {
                    $.modal.msgError('请先选择员工');
                    return;
                }
                $.operate.save(prefix + "/edit", $('#form-content-edit').serialize());
            }
        }
    </script>
</body>
</html>